<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>生成器函数</title>
	</head>
	<body>
		<script>
			// 模拟获取 用户数据 订单数据 商品数据
			function getUsers() {
				setTimeout(() => {
					let data = '用户数据';
					iter.next(data);
				},1000);
			}
			function getOrders() {
				setTimeout(() => {
					let data = '订单数据';
					iter.next(data);
				},1000);
			}
			function getGoods() {
				setTimeout(() => {
					let data = '商品数据';
					iter.next(data);
				},1000);
			}
			function * gen() {
				let user = yield getUsers();
				console.log(user);
				let order = yield getOrders();
				console.log(order);
				let good = yield getGoods();
				console.log(good);
			}
			let iter = gen();
			iter.next();
		</script>
	</body>
</html>